package cn.zhentao.dao;

import cn.zhentao.pojo.Dept;
import cn.zhentao.pojo.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface DeptMapper {
    @Select("select * from dept")
    @Results(
            id = "deptMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "dname", property = "dname"),
            @Result(column = "loc",property = "loc"),
            //关联属性
            @Result(column = "id",property = "emps",
                    many = @Many(select="cn.zhentao.dao.EmpMapper.findByDeptNo",fetchType = FetchType.LAZY))
    }
    )
    List<Dept> findAll();


    @Select("select * from dept where id=#{id}")
    List<Dept> findByNo();
}
